Fix problem with docker internal
networks
#350
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello, I found an issue while setting up
nginx-proxy
container for my network.I have the following setup:
--internal
parameterContainer with
nginx-proxy
connected to bothA
andB
networks. At the same time, containers with applications are connected only to 'B' network. When running such a config, I was always getting.After investigating, I find out that the issue comes from the fact that 'docker inspect' section
NetworkSettings.Ports
is always empty for internal networks, no matter which port you expose/publish. As the result we always have emptyaddresses
variable when we generate a template. Solution here is to take exposed ports from sectionConfig.ExposedPorts
whenNetworkSettings.Ports
is empty.How to reproduce:
Create internal network
docker network create 'test_network' --internal
Run httpd container connected on this network
docker run --network test_network --rm -e VIRTUAL_HOST=test.local -e VIRTUAL_PORT=80 httpd:2.4-alpine
Get latest nginx.tml
wget https://github.com/raw/nginx-proxy/nginx-proxy/main/nginx.tmpl
Run
docker run --network test_network -it --rm -v /run/docker.sock:/tmp/docker.sock -v $(pwd):/app/ jwilder/docker-gen /app/nginx.tmpl
You will see that in the
upstream
section of the generated configserver
directive is marked asdown
.Repeat all the steps but this time, on step 1, create a network without the
--internal
parameter.